<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript">
/**
 * 获取产品分类数据
 */
function getProductClassData(num){
    var tid='';
    var bid='';
    var item={};
    var html="<option value=''>-请选择-</option>";
    switch (num){
        case 1:
            $('#brand_id').html(html);
            $('#model_id').html(html);
            tid=$('#categoryId').val();
            item={'tid':tid};
            break;
        case 2:
            $('#model_id').html(html);
            tid=$('#categoryId').val();
            bid=$('#brand_id').val();
            item={'tid':tid,'bid':bid};
            break;
        default :
            alert('参数异常');
            return false;
    }
    var load=layer.load(2);
    $.post("<?=blang_url('ajax/ajax/getProductClassAll')?>",item,function(data){
        if(data){
            layer.close(load);
            if(data==101){
                alert('当前分类下没有任何数据');
            }else {
                var productData = JSON.parse(data);
                for (var i = 0; i < productData.length; i++) {
                    html += "<option value='" + productData[i]['sap_id'] + "'>" + productData[i]['name'] + "</option>";
                }
                switch (num) {
                    case 1:
                        $('#brand_id').html(html);
                        break;
                    case 2:
                        $('#model_id').html(html);
                        break;
                    default :
                        break;
                }
            }
        }
    });
}
</script>

<!--菜单 start-->
<?php $this->load->view('defaults/common/left');?>
<!--菜单 end-->
<div id="content">
    <div class="page-header">
        <div class="container-fluid">
          <h1>基项管理</h1>
          <?=$this->breadcrumb->generateHTML();?>
        </div>
    </div>
    <div class="container-fluid">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i>RepairItem List</h3>
          </div>
          <div class="panel-body">
            <div class="well" style="padding:0 19px;">
              <div class="row">
                <form action="<?=blang_url('orders/Product_repair_item/')?>" method="post" name="searchform" >
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label" for="input-name">name</label>
                            <input class="form-control" name="keyword"  value="<?=$keyword?>" placeholder="name" size="34" />
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="input-name">category</label>
                            <select class="form-control" name="category" id="categoryId" onchange="getProductClassData(1)">
                                <option value="" >--category--</option>
                                <?php foreach ($categoryList as $rs):?>
                                    <option value="<?=$rs['id'].'_'.$rs['sap_id']?>" <?=$optCategory[$rs['id'].'_'.$rs['sap_id']]?> > <?=$rs['name_'.$curLang]?> </option>
                                <?php endforeach;?>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label" for="input-name">brand</label>
                            <select class="form-control" name="brand_id" id="brand_id" onchange="getProductClassData(2)">
                                <option value="">-brand-</option>
                                <?php if($brandList){foreach($brandList as $bs){?>
                                    <option value="<?=$bs['sap_id']?>" <?=$optBrand[$bs['sap_id']]?>><?=$bs['name']?></option>
                                <?php }}?>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="input-name">model</label>
                            <select class="form-control" name="model_id" id="model_id">
                                <option value="">-model-</option>
                                <?php if($modelList){foreach($modelList as $ms){?>
                                    <option value="<?=$ms['sap_id']?>" <?=$optModel[$ms['sap_id']]?>><?=$ms['name']?></option>
                                <?php }}?>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-4">
                        <div class="form-group">
                            <label class="control-label" for="input-name">grade</label>
                            <select class="form-control" name="grade">
                                <option value="" >--grade--</option>
                                <?php foreach ($gradeList as $rs):?>
                                    <option value="<?=$rs['id']?>" <?=$optGrade[$rs['id']]?> > <?=$rs['name_'.$curLang]?> </option>
                                <?php endforeach;?>
                            </select>
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="input-name">isDefault</label>
                            <select class="form-control" name="isDefault">
                                <option value="">-defaults-</option>
                                <option value='0' <?=$optDefault[0]?>>No</option>
                                <option value='1' <?=$optDefault[1]?>>Yes</option>
                            </select>
                        </div>
                    </div>
                    <div class="col-sm-12">
                       <input class="btn btn-primary pull-right" style="padding:8px 35px;margin-bottom: 19px;" type="submit" name="searchSubmit" value="<?=lang('public_cx')?> " />
                    </div>
                </form>
                
              </div>
            </div>
            <div class="table-responsive">
                <table class="table table-bordered table-hover oms-table">
                  <thead>
                    <tr>
                        <th class="text-left">id</th>
                        <th class="text-left">产品类型</th>
                        <th class="text-left">维修级别</th>
                        <th class="text-left">中文名称</th>
                        <th class="text-left">英文名称</th>
                        <th class="text-right">是否默认</th>
                        <th class="text-right">状态</th>
                        <th class="text-right">用户</th>
                        <th class="text-right">日期</th>
                        <th class="text-right">操作</th>
                    </tr>
                  </thead>
                  <tbody>
                    <?php if($dataList): foreach ($dataList as $key=>$rs):?>
                    <tr>
                        <td class="text-left"><?=$rs['id']?></td>
                        <td class="text-left"><?=$rs['categoryName']?></td>
                        <td class="text-left"><?=$rs['gradeName']?></td>
                        <td class="text-left"><?=$rs['name_ch']?></td>
                        <td class="text-left"><?=$rs['name_en']?></td>
                        <td class="text-right"><?=$rs['isDefault']?></td>
                        <td class="text-right"><?=$rs['availableName']?></td>
                        <td class="text-right"><?=$rs['add_user']?></td>
                        <td class="text-right"><?=$rs['add_time']?></td>
                        <td class="text-right">
                            <a class="btn btn-primary btn-sm" href="<?=blang_url('orders/Product_repair_item/edit/'.$rs['id'])?>" title="edit"><i class="fa fa-edit"></i></a>
                            <a class="btn btn-danger btn-sm" href="<?=blang_url('orders/Product_repair_item/del/'.$rs['id'])?>" onclick="return confirm('确定要删除此维修项吗？')" title="delete"><i class="fa fa-trash-o"></i></a>
                        </td>
                    </tr>
                    <?php endforeach; else:?>
                        <tr><td colspan="10" class="emptyNumber"><?=lang('public_mygdsj')?>....</td></tr>
                    <?php endif; ?>
                </tbody>
                </table>
                <?php if($show_pages):?>
                <div class="page">
                    <?=$show_pages?>
                </div>
                <?php endif;?>
            </div>
          </div>
        </div>
    </div>

</div>